/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SviluppoCliente.java
 *
 * Created on 18-feb-2009, 10:51:35
 */

package org.monopoly.sviluppo;

import javax.swing.DefaultListModel;
import org.monopoly.comunicazione.Elemento;
import org.monopoly.comunicazione.Messaggio;

/**
 *
 * @author Administrator
 */
public class SviluppoCliente extends javax.swing.JFrame {

    /** Creates new form SviluppoCliente */
    public SviluppoCliente() {
        initComponents();

        new Cliente(this).start();

    }

    public void aggiornaListaStanze(Messaggio m){
        DefaultListModel modello = new DefaultListModel();

        for(Elemento e : m.getParametri()){
            if("Stanza".equals(e.getA())){
                modello.addElement(e.getB());
            }else{
                modello.addElement("--> " + e.getB());
            }
        }

        listaStanze.setModel(modello);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        listaStanze = new javax.swing.JList();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Lista stanze e clienti");

        jScrollPane1.setViewportView(listaStanze);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(132, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new SviluppoCliente().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JList listaStanze;
    // End of variables declaration//GEN-END:variables

}
